import Layout from "@/page/index";
import lightLayout from "@/page/indexLightTheme";
import darkLayout from "@/page/indexDarkTheme";
import simpleLayout from "@/page/indexSimpleTheme";
import eveningLayout from "@/page/indexEveningTheme";
import { getStore } from "@/util/store";
import website from "@/config/website";

/**
 * 根据主题  改变layout component
 * **/
let themeName = getStore({ name: "themeName" }) || website.defaultTheme;
let layoutObj = {
  path: "/myiframe",
  redirect: "/myiframe",
  children: [
    {
      path: ":routerPath",
      name: "iframe",
      component: () =>
        (/* webpackChunkName: "myiframe" */ "@/components/iframe/main"),
      props: true
    }
  ]
};
switch (themeName) {
  case "default":
    layoutObj.component = Layout;
    break;
  case "lightTheme":
    layoutObj.component = lightLayout;
    break;
  case "darkTheme":
    layoutObj.component = darkLayout;
    break;
  case "simpleTheme":
    layoutObj.component = simpleLayout;
    break;
  case "eveningTheme":
    layoutObj.component = eveningLayout;
    break;
}
var routes = [
  {
    path: "/login",
    name: "登录页",
    component:resolve=>require(["@/page/login/index"],resolve),
    meta: {
      keepAlive: true,
      isTab: false,
      isAuth: false
    }
  },
  {
    path: "/lock",
    name: "锁屏页",
	component:resolve=>require(["@/page/lock/index"],resolve),
    meta: {
      keepAlive: true,
      isTab: false,
      isAuth: false
    }
  },
  // 表单设计 运行 iframe空页面
  {
    path: "/quick-development/preview.html",
    component:resolve=>require(["@/components/error-page/empty"],resolve),
  },
  {
    path: "/404",
	component:resolve=>require(["@/components/error-page/404"],resolve),
    name: "404",
    meta: {
      keepAlive: true,
      isTab: false,
      isAuth: false
    }
  },
  {
    path: "/403",
	component:resolve=>require(["@/components/error-page/403"],resolve),
    name: "403",
    meta: {
      keepAlive: true,
      isTab: false,
      isAuth: false
    }
  },

  {
    path: "/500",
	component:resolve=>require(["@/components/error-page/500"],resolve),
    name: "500",
    meta: {
      keepAlive: true,
      isTab: false,
      isAuth: false
    }
  },
  {
    path: "/",
    name: "主页",
    redirect: "/wel"
  },
  {
    path: "*",
    redirect: "/404"
  },
  {
    path: "/parser",
    name: "parser",
	component:resolve=>require(["@/components/parser/example/Index.vue"],resolve)
  },
  {
    path: "/tinymce",
    name: "tinymce",
	component:resolve=>require(["@/components/tinymce/example/Index.vue"],resolve)
  },
  {
    path: "*/bi/view/:id",
    name: "view",
	component:resolve=>require(["@/views/BI/preview"],resolve)
  },
  {
    path: "*/bi/view/:id/index",
    name: "view",
	component:resolve=>require(["@/views/BI/preview"],resolve)
  },
  {
    path: "*/bi/navigate",
    name: "view",
	component:resolve=>require(["@/views/BI/navigate"],resolve)
  },
  {
    path: "*/centerboard",
    name: "中心看板",
	component:resolve=>require(["@/centerboard/index"],resolve)  
  },
  {
    path: "*/projectboard",
    name: "项目看板",
	component:resolve=>require(["@/centerboard/index2"],resolve)
  },
  {
    path: "*/report-frame/:id",
    name: "report",
	component:resolve=>require(["@/views/ReportModule/ReportFrame.vue"],resolve),
    meta: {
      keepAlive: true,
      isTab: true,
      isAuth: false
    }
  },
  {
    path: "/message-link/:operation/:id",
    name: "message-link",
    meta: {
      isTab: false
    },
	component:resolve=>require(["@/views/MessageLink/Index.vue"],resolve)
  }
];

//加入layout 组件
routes.push(layoutObj);
export default routes;
